<?php
/**
 * Created by PhpStorm.
 * User: zmit
 * Date: 8/9/17
 * Time: 6:22 PM
 */
namespace AdminBundle\Controller;

class CompanyController extends AdminController
{
    /*
     * 企业信息列表
     */
    public function companyListAction()
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $conn = $this->get("database_connection");
        $data['medal'] = $conn->fetchAll("SELECT * FROM medal WHERE 1 ");
        $data['teac_admin'] = $conn->fetchAll("SELECT id,nickname FROM admin WHERE admin_role_id = 4 AND district_id = '". $this->get("session")->get("district_id") ."'");
        $data["category"] = $conn->fetchAll("SELECT * FROM company_category WHERE 1 ");
        $data["attribute"] = $conn->fetchAll("SELECT * FROM company_attribute WHERE 1 ");

        return $this->render("AdminBundle:Company:companyList.html.twig",array("data"=>$data));
    }

    /*
     * 企业基本信息
     */
    public function companyBaseAction($id)
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $data = $this->getApiData("ApiBundle:Platform/Company:companyDetailMessage",array("id"=>$id));

        return $this->render("AdminBundle:Company:companyBaseMessage.html.twig",array("data"=>$data));
    }

    /*
     * 企业其他信息
     */
    public function companyOtherAction($id)
    {
        if(!$this->get("session")->get("admin_id")){

            return $this->render('AdminBundle:Auth:login.html.twig');
        }

        $data = $this->getApiData("ApiBundle:Platform/Company:companyOtherMessage",array("id"=>$id));
        return $this->render("AdminBundle:Company:companyOtherMessage.html.twig",array("data"=>$data));
    }
}